package com.wanxi.step07test.controller;


import com.wanxi.step07test.dto.ResultDTO;
import com.wanxi.step07test.model.NewsTypeModel;
import com.wanxi.step07test.service.impl.NewsTypeServiceImpl;
import com.wanxi.step07test.util.Tool;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@CrossOrigin
public class NewsTypeController {


    @Autowired
    private NewsTypeServiceImpl newsTypeService;

    @PreAuthorize("hasAuthority('newsType:findAll')")
    @RequestMapping("/back/newsType/findAll")
    @ResponseBody
    public ResultDTO findAll(NewsTypeModel newsType) {
        ResultDTO resultDTO = newsTypeService.findAll(newsType);
        return resultDTO;
    }

    @PreAuthorize("hasAuthority('newsType:add')")
    @RequestMapping("/back/newsType/add")
    @ResponseBody
    public ResultDTO add(NewsTypeModel newsType) {
        ResultDTO resultDTO = newsTypeService.add(newsType);
        return resultDTO;
    }


    @PreAuthorize("hasAuthority('newsType:delete')")
    @RequestMapping("/back/newsType/delete")
    @ResponseBody
    public ResultDTO delete(NewsTypeModel newsType) {
        ResultDTO resultDTO = newsTypeService.delete(newsType);
        return resultDTO;
    }

    @PreAuthorize("hasAuthority('newsType:findById')")
    @RequestMapping("/back/newsType/findById")
    @ResponseBody
    public ResultDTO findById(NewsTypeModel newsType) {
        ResultDTO resultDTO = newsTypeService.findById(newsType);
        return resultDTO;
    }

    @PreAuthorize("hasAuthority('newsType:update')")
    @RequestMapping("/back/newsType/update")
    @ResponseBody
    public ResultDTO update(NewsTypeModel newsType) {
        ResultDTO resultDTO = newsTypeService.update(newsType);
        return resultDTO;
    }



}
